figure()
subplot(2,3,1)
x = log(inflation); y = log(R_share);
scatter(x, y,  15,'filled'), hold on
title('Raw Data','FontSize',14)
ylabel('R share (in log)','fontsize',14)
% h = lsline;
% set(h(1),'color','k','lineWidth',2)
bestfit = polyfit(x,y,1);
%mdl     = fitlm(x,y)
yfit = polyval(bestfit, x);
plot(x,yfit)
SStot = sum((y - mean(y)).^2);
SSres = sum((y - yfit).^2);
Rsq   = 1 - SSres / SStot
hold on
%theString = sprintf('y = %.2f x  %.2f', bestfit(1), bestfit(2));
theString = sprintf('Slope: %.2f', bestfit(1));
text(0.1,-2.2,theString, 'FontSize', 14);
mdl = fitlm(x,y)
hold off

subplot(2,3,2)
x = inflation_trend; y = R_share_trend;
scatter(x, y,  15,'filled'), hold on
title('Trend Components','FontSize',14)
%h = lsline;
%set(h(1),'color','k','lineWidth',2)
bestfit = polyfit(x,y,1);
%mdl     = fitlm(x,y)
yfit = polyval(bestfit, x);
plot(x,yfit)
SStot = sum((y - mean(y)).^2);
SSres = sum((y - yfit).^2);
Rsq   = 1 - SSres / SStot
hold on
%theString = sprintf('y = %.2f x  %.2f', bestfit(1), bestfit(2));
theString = sprintf('Slope: %.2f', bestfit(1));
text(0.02,-2,theString, 'FontSize', 14);
mdl = fitlm(x,y)
hold off

subplot(2,3,3)
x = inflation_cycle; y = R_share_cycle;
scatter(x, y,  15,'filled'), hold on
title('Cyclical Components','FontSize',14)
% h = lsline;
% set(h(1),'color','k','lineWidth',2)
bestfit = polyfit(x,y,1);
%mdl     = fitlm(x,y)
yfit = polyval(bestfit, x);
plot(x,yfit)
SStot = sum((y - mean(y)).^2);
SSres = sum((y - yfit).^2);
Rsq   = 1 - SSres / SStot
hold on
%theString = sprintf('y = %.2f x + %.2f', bestfit(1), bestfit(2));
theString = sprintf('Slope: %.2f', bestfit(1));
text(0.03, 0,theString, 'FontSize', 14);
mdl = fitlm(x,y)
hold off

subplot(2,3,4)
x = log(inflation); y = log(P_share);
scatter(x, y,  15,'filled'), hold on
xlabel('Gross inflation (in log)', 'FontSize', 12)
ylabel('P share (in log)','fontsize',14)
% h = lsline;
% set(h(1),'color','k','lineWidth',2)
bestfit = polyfit(x,y,1);
%mdl     = fitlm(x,y)
yfit = polyval(bestfit, x);
plot(x,yfit)
SStot = sum((y - mean(y)).^2);
SSres = sum((y - yfit).^2);
Rsq   = 1 - SSres / SStot
hold on
%theString = sprintf('y = %.2f x  %.2f', bestfit(1), bestfit(2));
theString = sprintf('Slope: %.2f', bestfit(1));
text(0.06, -1.5, theString, 'FontSize', 14);
mdl = fitlm(x,y)
hold off

subplot(2,3,5)
x = inflation_trend; y = P_share_trend;
scatter(x, y,  15,'filled'), hold on
xlabel('Gross inflation (in log)', 'FontSize', 12)
% h = lsline;
% set(h(1),'color','k','lineWidth',2)
bestfit = polyfit(x,y,1);
%mdl     = fitlm(x,y)
yfit = polyval(bestfit, x);
plot(x,yfit)
SStot = sum((y - mean(y)).^2);
SSres = sum((y - yfit).^2);
Rsq   = 1 - SSres / SStot
mdl = fitlm(x,y)
hold on
%theString = sprintf('y = %.2f x  %.2f', bestfit(1), bestfit(2));
theString = sprintf('Slope: %.2f', bestfit(1));
text(0.05,-1.4,theString, 'FontSize', 14);
hold off

subplot(2,3,6)
x = inflation_cycle; y = P_share_cycle;
scatter(x,y, 15,'filled'), hold on
xlabel('Gross inflation (in log)','FontSize', 14)
%xlim([-0.2,0.1])
% h = lsline;
% set(h(1),'color','k','lineWidth',2)
bestfit = polyfit(x,y,1);
%mdl     = fitlm(x,y)
yfit = polyval(bestfit, x);
plot(x,yfit)
SStot = sum((y - mean(y)).^2);
SSres = sum((y - yfit).^2);
Rsq   = 1 - SSres / SStot
hold on
%theString = sprintf('y = %.2f x  %.2f', bestfit(1), bestfit(2));
theString = sprintf('Slope: %.2f', bestfit(1));
text(0.02, -0.2, theString, 'FontSize', 14);
mdl = fitlm(x,y)
hold off